package com.itheima.mytext10;

public class Cook extends Thread//厨师
{
    @Override
    public void run() {

        while(true)
        {
            synchronized (Desk.obj)
            {
                if(Desk.count==0)
                    break;
                else
                {
                    //是否有面条
                    if(Desk.foodflag==0)//说明此时没有面条，需要做面条
                    {
                        System.out.println("厨师做了一碗面条");
                        Desk.foodflag=1;//表示有面条
                        Desk.obj.notifyAll();//唤醒吃货来吃
                    }
                    else//有面条，就需要等待吃货去吃
                    {
                        try {
                            Desk.obj.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                    }
                }
            }
        }
    }
}
